package com.edt.ichannel.api.controller;


import cc.edt.iceutils3.json.IceFastJsonUtils;
import com.edt.ichannel.api.common.controller.BaseController;
import com.edt.ichannel.api.common.entity.ActionResult;
import com.edt.ichannel.api.entiy.local.EntityForCallUnicomPayBatch;
import com.edt.ichannel.api.entiy.local.EntityFormUnicomPayParam;
import com.edt.ichannel.api.entiy.local.HttpPostParamsWoPay;
import com.edt.ichannel.api.service.PayService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * CreateBy:zyp
 * CreateDate:2018/3/8
 * UpdateBy:
 * UpdateDate:
 * Description:支付接口
 **/
@Controller
@RequestMapping("/pay")
public class payController extends BaseController {


    @Resource
    private PayService payService;



    /**
     * 沃支付接口
     */
    @RequestMapping(value = "wo")
    @ResponseBody
    public void wo(HttpPostParamsWoPay params)  {
        ActionResult actionResult = payService.pay(params);
        WriterToPageByJson(actionResult);
    }


    /**
     * 沃支付接口 给拓展人提现用的
     */
    @RequestMapping(value = "woPayStaff")
    @ResponseBody
    public void woPayStaff(HttpPostParamsWoPay params) {
        ActionResult actionResult = payService.payStaff(params);
        WriterToPageByJson(actionResult);
    }



    /**
     * 联通支付
     */
    @RequestMapping(value = "unicomPay")
    @ResponseBody
    public void unicomPay(  EntityFormUnicomPayParam params) {
        ActionResult actionResult = payService.unicomPay(params);
        WriterToPageByJson(actionResult);
    }


    /**
     * 联通支付
     */
    @RequestMapping(value = "unicomPayBatch")
    @ResponseBody
    public void unicomPayBatch(EntityForCallUnicomPayBatch params) {
        ActionResult actionResult = payService.unicomPayBatch(params);
        WriterToPageByJson(actionResult);
    }


    /**
     * 沃支付回调(测试)
     */
    @RequestMapping(value = "callBack")
    @ResponseBody
    public void callBack(HttpPostParamsWoPay params,HttpServletRequest request) {
        System.out.println("--------接收参数："+IceFastJsonUtils.toJsonString(params));
        System.out.println("-------------所有参数："+request.getParameterMap());
        WriterToPageByString("success");
    }






}
